//审核详情页
<template>
<div>
    <common-header
        :title="title"
        :type=3></common-header>
    <div class="mui-content">
        <div class="swipe-div">
            <mt-swipe :auto="0">
                <mt-swipe-item class="slide1" v-for="(img, index) in imgList" :key="index">
                    <a href="javascript: void(0)">
                        <img :src="img" preview="0"/>
                    </a>
                </mt-swipe-item>
            </mt-swipe>
        </div>
        <div class="audit-details">
            <ul>
                <li>
                    <p class="audit-details-title">样衣编号:</p>
                    <p class="audit-details-conts">{{ data.sampleId }}</p>
                </li>
                <li>
                    <p class="audit-details-title">大类:</p>
                    <p class="audit-details-conts">{{ data.dlText }}</p>
                </li>
                <li>
                    <p class="audit-details-title">货号:</p>
                    <p class="audit-details-conts">{{ data.pcode }}</p>
                </li>
                <li>
                    <p class="audit-details-title">小类:</p>
                    <p class="audit-details-conts">{{ data.xlText }}</p>
                </li>
                <li>
                    <p class="audit-details-title">波段号:</p>
                    <p class="audit-details-conts">{{ data.bandname }}</p>
                </li>
                <li>
                    <p class="audit-details-title">合作方式:</p>
                    <p class="audit-details-conts">{{ data.jyfs }}</p>
                </li>
                <li>
                    <p class="audit-details-title">供货商编码:</p>
                    <p class="audit-details-conts">{{ data.supplierid }}</p>
                </li>
                <li>
                    <p class="audit-details-title">供货商:</p>
                    <p class="audit-details-conts">{{ data.vendername }}</p>
                </li>
            </ul>
        </div>
        <div class="audit-regula">
            <div class="audit-regula-title">
                <h1>总得分</h1>
                <label class="decision-details-label decision-details-zong">{{ resolve.totscore }}</label>
            </div>
            <div class="audit-regula-cont">
                <ul>
                    <li>
                        <div class="mui-input-row mui-checkbox decision-details-box">
                            <label>买手</label>
                            <label class="decision-details-label">{{ resolve.buyer }}</label>
                        </div>
                    </li>
                    <li>
                        <div class="mui-input-row mui-checkbox decision-details-box">
                            <label>店长</label>
                            <label class="decision-details-label">{{ resolve.Shopowner }}</label>
                        </div>
                    </li>
                    <li>
                        <div class="mui-input-row mui-checkbox decision-details-box">
                            <label>采购经理</label>
                            <label class="decision-details-label">{{ resolve.buyManager }}</label>
                        </div>
                    </li>
                    <li>
                        <div class="mui-input-row mui-checkbox decision-details-box">
                            <label>外围评审</label>
                            <label class="decision-details-label">{{ resolve.other }}</label>
                        </div>
                    </li>
                    <li>
                        <div class="mui-input-row mui-checkbox decision-details-box">
                            <label>买手团队</label>
                            <label class="decision-details-label">{{ resolve.buyertm }}</label>
                        </div>
                    </li>
                    <li>
                        <div class="mui-input-row mui-checkbox decision-details-box">
                            <label>外围团队</label>
                            <label class="decision-details-label">{{ resolve.othertm }}</label>
                        </div>
                    </li>
                </ul>
            </div>
        </div>
        <div class="audit-button">
            <ul>
                <li class="audit-false decision-false">
                    <button type="button" class="mui-btn mui-btn-yellow" @click="eliminate">淘汰</button>
                </li>
                <li class="audit-sure">
                    <button type="button" class="mui-btn mui-btn-blue" @click="create">生成初选单</button>
                </li>
            </ul>
        </div>
    </div>
</div>
</template>
<script>
import { mapState, mapMutations } from 'vuex'
import commonHeader from '@/components/commonHeader.vue'
import { Swipe, SwipeItem } from 'mint-ui'
import API from '@/service/api'
export default {
    components: { commonHeader, Swipe, SwipeItem },
    data() {
        return {
            title: '海选决策',
            data: {},
            resolve: {},
            imgList: [],
        }
    },
    computed: {
        ...mapState( [ 'sample_id', 'sample_no' ] ) 
    },
    methods: {
        ...mapMutations( [ 'UPDATE_SHOW_LOADING' ] ),
        async initialization() {
            this.resolve = this.$route.params.record
            //获取基本信息
            this.data = await API.currency.getSampleDetail({ ID: this.sample_no })
            //获取样衣图片列表
            let imgs = await API.currency.getSampleImgs({ sampleId: this.sample_id })
            for(let i = 1; i<6; i++) {
                const img = imgs[`limg${i}`]
                if(img) this.imgList.push(img)
            }
            //启动图片预览
            this.$previewRefresh()
            this.UPDATE_SHOW_LOADING(false)
        },
         //淘汰
        eliminate(status) {
            this.UPDATE_SHOW_LOADING(true)
            API.resolve.eliminate({ ids: this.sample_no }).then(res=> {
                this.handle(res)
            })
        },
        create() {
            this.UPDATE_SHOW_LOADING(true)
            API.resolve.createBill({ ids: this.sample_id }).then(res=> {
                this.handle(res)
            })
        },
        handle(res) {
            this.UPDATE_SHOW_LOADING(false)
            if(res.code == 1) {
                this.$success()
                setTimeout(()=>{
                    this.$router.push( { name: 'resolve' } )
                },1000)
            }else this.$error(res.errMsg)
        }
    },
    created() {
       this.initialization()
    } 
}
</script>
<style lang="less" scoped>
.audit-button{
    .mui-btn-yellow {
        background-color: #ffaf00 !important;
        color: #ffffff
    }
}
</style>